

#include "jkj_ui.h"
#include "menu_ui_logic.h"
#include "qtab_ui_logic.h"
//ShoppingCartUI *newBuyCart = nullptr;
JkjUi::JkjUi(QWidget *parent)
    : QWidget{parent}
{
    init();
}



void JkjUi::init()
{
    qStackedWidget = new QStackedWidget;

    //auto *newPage4 = new UserPersonal;
    newPage4= new UserPersonal();
    newBuyCart = new ShoppingCartUI();
    auto *newYanChu = new QTabUi(newBuyCart);
    qStackedWidget->addWidget(newYanChu);
    qStackedWidget->addWidget(newPage4);
    qStackedWidget->addWidget(newBuyCart);

    extern EventGridWidget *gridWidget;
    QTabUiLogic *qtabuiLogic = new QTabUiLogic(newYanChu, gridWidget, this);
    UserPersonalLogic *uplogic =new UserPersonalLogic(newPage4);
    this->setFixedSize(1680, 930);

    // Disable maximize and minimize buttons
    this->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);

    this->setAttribute(Qt::WA_StyledBackground, true);
    this->setWindowTitle(tr("PiliPili_Buy"));
    this->setWindowIcon(QIcon(QString::fromUtf8(":/icon/dark_activity.png")));
    this->setStyleSheet("background-color: #FFFFFF");

    sidebarWidget = new MenuUi;
    MenuUiLogic *menuLogic = new MenuUiLogic(sidebarWidget, this);

    auto *contentLayout = new QVBoxLayout;
    content = new QWidget;
    contentLayout->addWidget(qStackedWidget);
    content->setLayout(contentLayout);

    QSplitter *splitter = createVerticalSplitter(this, sidebarWidget, content, Qt::Horizontal, 200, 600);

    auto *layout = new QVBoxLayout;
    layout->addWidget(splitter);
    this->setLayout(layout);
}
QSplitter *JkjUi::createVerticalSplitter(QWidget *parent,
                                         QWidget *content1,
                                         QWidget *content2,
                                         Qt::Orientation orientation,
                                         int size1,
                                         int size2)
{
    auto *splitter = new QSplitter(orientation, parent);
    splitter->addWidget(content1);
    splitter->addWidget(content2);
    splitter->setSizes(QList<int>() << size1 << size2);
    QSplitterHandle *splitterHandle1 = splitter->handle(1);
    splitterHandle1->setEnabled(false);

    return splitter;
}
JkjUi::~JkjUi()
{
    qDebug() << "调用析构函数Jkjui（）";
}
